home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / SDKs / PCI Driver Development Kit / • Documentation / Open Firmware / "display" device extensions next >
Encoding:
Text File  |  1996-08-20  |  11.4 KB  |  164 lines  |  [TEXT/ttxt]

  1. Terminal Emulator Support Package Extensions
  2.  
  3. Note:  the information presented here is preliminary.  In particular, the exact values for the color table initialization may change.
  4.  
  5. 16-Color Extension
  6. This extension defines an expanded 16-color model, primarily for use by Client Programs.  The model supports what has been described as ANSI-graphics, PC-ANSI graphics, etc.  The extension requires the presence of two features.  The first is that the Open Firmware implementation has to have a version of the Terminal Emulator that supports the expanded escape sequences.  This is indicated (for use by Client Programs) by the presence of a new property ("iso6429-1983-colors") in a new /packages/terminal-emulator node.  The second requirement is that the "display" driver have support for the CLUT setup required by the Terminal Emulator.  This is indicated by having the "display" driver publish the "iso6429-1983-colors" property.  The Open Firmware Terminal Emulator will initialize the values of its foreground and background color values to their appropriate values, depending upon the presence of this property in the "display" package.
  7.  
  8. Note:  see the discussion in Color Table (CLUT) Initialization for what has to be done by a "display" driver to detect the presence of the support of the Terminal Emulator, and the implications for how the driver has to initialize its CLUT.
  9.  
  10. IEEE Std 1275-1994 defines the behavior of the Terminal Emulator Support Package (see Annex B of [1]).  Annex B of [1] assumes that the Terminal Emulator Support Package implements certain escape sequences from the set defined by ANSI X3.64. The extension described here corresponds to ISO 6429-1983, as defined by [2].  An implementation of Open Firmware for PowerPC is required to support additional graphic renditions (via the SGR - Select Graphic Rendition - ESC[#m) beyond those specified in Annex B.
  11.  
  12. In order for these extensions to be used, the FCode device driver for a display device (i.e., a device whose "device_type" property has the value "display") shall initialize the first 16 entries of its color table to appropriate values (see Color Table Initialization).  These values assume that the color is represented by the low-order 3 bits of the color index and that the bit corresponding to a value of 8 represents the intensity.  The ISO 6429-1983 standard provides parameter values to independently control the color of foreground (30-37) and background (40-47).  The intensity is set separately (1-2), and must be issued before the color control; 1 -> color, 2 -> color+8.
  13.  
  14. The expanded model of the Terminal Emulator is that there is a "current" background and foreground color (index), each of whose value is 0-15, corresponding to the first 16 entries of the color table.  In positive image mode, pixels corresponding to a font (logo) bit set (1) shall be set to the foreground color;  pixels corresponding to a font (logo) bit clear (0) shall be set to the background color. When in negative image mode, the roles of foreground and background are reversed.
  15.  
  16. The default rendition shall be positive image mode, background=15 and foreground=0, thus producing black characters on a bright white background.
  17.  
  18. The following table describes the effect of executing the SGR escape sequence with the specified parameter.
  19.  
  20.     Param   Interpretation
  21.     0       default rendition
  22.     1       bold (increased intensity)
  23.     2       faint (decreased intensity)
  24.     7       negative image
  25.     27      positive image
  26.     30      black foreground
  27.     31      red foreground
  28.     32      green foreground
  29.     33      yellow foreground
  30.     34      blue foreground
  31.     35      magenta foreground
  32.     36      cyan foreground
  33.     37      white foreground
  34.     40      black background
  35.     41      red background
  36.     42      green background
  37.     43      yellow background
  38.     44      blue background
  39.     45      magenta background
  40.     46      cyan background
  41.     47      white background
  42.  
  43.     Table  1.  SGR Parameters
  44.  
  45. Display devices
  46. This section defines additional behavior of display devices (e.g., device_type = "display") for Open Firmware implementations that support the Terminal Emulator Extensions.
  47.  
  48. Color Table (CLUT) Initialization
  49. The core specification of Open Firmware defines a Terminal Emulation Support Package that, while defined for 8-bit pixels, does not include support for colors.  In order to support the Terminal Emulator Extensions, Open Firmware implementations will support additional Select Graphic Rendition parameters in order to allow client programs to display characters (and logos) using a 16-color model.
  50.  
  51. CLUT Initialization for older Open Firmware implementations
  52. Not every Open Firmware will support the extensions.  For use in those systems, the "display" FCode driver has to initializat the CLU in a manner consisten with the original 1275 model.  That model assumed that the 8-bit pixel values for ForeGround and that BackGround are 0xFF and 0x00, respectively.  Note that the interpretation of the value 0 is exactly opposite!  Therefore, the FCode driver must detect if the Open Firmware is using the new 16-color extensions, or not.
  53.  
  54. The following code snippet does that:
  55.  
  56.   h# 168 get-token drop  ['] ferror  <> if
  57.       \ initialize for the new 16-color CLUT model
  58.     else
  59.       \ intialize for the original 1275 interpretation
  60.     then
  61.  
  62. The code above works by detecting whether non-error code exists for the new FCode assigned to foreground-color.
  63.  
  64. CLUT Initialization for the 16-color extensions
  65. For the expanded Terminal Emulation support to work, Open Firmware device drivers for "display" devices shall initialize the first 16 entries of their color table to values defined in Table 2.Color Table Values.  Note that the table values are defined in terms of percentage of full saturation color for each of the primary RGB colors.
  66.  
  67.         Index   Red     Green   Blue    Color
  68.         0       0       0       0       Black
  69.         1       0       0       2/3     Blue
  70.         2       0       2/3     0       Green
  71.         3       0       2/3     2/3     Cyan
  72.         4       2/3     0       0       Red
  73.         5       2/3     0       2/3     Magenta
  74.         6       2/3     1/3     0       Brown
  75.         7       2/3     2/3     2/3     White
  76.         8       1/3     1/3     1/3     Gray
  77.         9       1/3     1/3     1       Light Blue
  78.         10      1/3     1       1/3     Light Green
  79.         11      1/3     1       1       Light Cyan
  80.         12      1       1/3     1/3     Light Red
  81.         13      1       1/3     1       Light Magenta
  82.         14      1       1       1/3     Yellow
  83.         15      1       1       1       Bright White
  84.         Table  4.  Color Table Values
  85.  
  86.  
  87. "display" device standard properties
  88. In addition to the standard properties defined by Open Firmware for display devices, the following properties shall be present.
  89.  
  90. "iso6429-1983-colors"
  91.      Standard property, with a null prop-encoded array, that indicates that the the device driver supports the
  92.      additional methods required for this extension.
  93.  
  94. "width"
  95.      Standard property, encoded as with encode-int, that represents the visible width of the display in pixels.
  96.  
  97. "height"
  98.      Standard property, encoded as with encode-int, that represents the visible height of the display in pixels.
  99.  
  100. "linebytes"
  101.      Standard property, encoded as with encode-int, that represents the address offset between a pixel on one
  102.      scan line and that same relative horizontal pixel position on the immediately following scan line.
  103.  
  104. "depth"
  105.      Standard property, encoded as with encode-int, that represents the number of bits in each pixel.
  106.  
  107. Graphics Extension
  108. Another, somewhat independent, extension that has been defined is a so-called "graphics" extension.  This extension assumes that a "display" driver supports a full 8-bit pixel format, including a CLUT that can represent 256 colors.  The first 16 colors are defined by the 16-color Extension described above.  This extension adds support for more colors and for a limited "graphics" capability.
  109.  
  110. The color support is designed to let Client Programs have control of the color-space by providing access to the CLUT by a set of new methods (set-colors, get-colors, color!, color@), defined below.
  111.  
  112. The graphics support defines methods (draw-rectangle, read-rectangle, fill-rectangle) that allow a Client Program to read and write rectangular areas of the display buffer.
  113.  
  114. "display" device standard methods
  115. This section defines additional methods that "display" devices should implement in order to be compliant with the Graphics Extensions.  These methods assume that the device supports at least 16 colors using the R-G-B color model, and that a Color Lookup Table (CLUT) exists that can be read and written.  The model assumes 8-bit values for each of the R-G-B components of the colors, where 0x00 implies no color and 0xFF is full saturation of the component.  If fewer bits are available, the corresponding entries should be scaled appropriately.
  116.  
  117. Individual color entries are specified by their R-G-B values, using 8 bits for each.  Each color is represented by an "index".
  118.  
  119. Note: The index values for the 16-color Extension are in the range 0..15;  however, most display hardware will support at least 256 colors.
  120.  
  121. The following methods allow access to the CLUT from Client Programs (and, the User Interface):
  122.  
  123. set-colors      ( adr index #indices -- )
  124.       This method allows the setting of a number of consecutive colors, starting at the index color,
  125.      for #indices colors.  adr is the address of a table of packed R-G-B components.
  126.  
  127. get-colors      ( adr index #indices -- )
  128.      This method allows the reading of a number of consecutive colors, starting at the index color,
  129.      for #indices colors.  adr is the address of a table that will be filled in with packed R-G-B
  130.      components.
  131.  
  132. color!          ( r g b index -- )
  133.      This method allows the setting of a single color value, specified by index.  r, g and b are
  134.      the values to be placed into the Red, Green and Blue components, respectively.
  135.  
  136. color@          ( index -- r g b )
  137.      This method allows the reading of the color components  of a single color value, specified
  138.      by index.   r, g and b are the values of the Red, Green and Blue components, respectively.
  139.  
  140. The following methods support a minimal "bit-mapped" graphics capabilities for Client programs:
  141.  
  142. draw-rectangle   ( adr x y w h -- )
  143.      This method copies a pixel-map (consisting of consecutive bytes of index values) to the screen.
  144.      The x,y parameters specify the horizontal and vertical location of the top-left corner of the rectangle;
  145.      0,0 represents the top-left pixel of the screen.  The width and height of the source rectangle are given
  146.      by the w,h parameters.  The pixel map is specified by the adr argument and consists of an array of
  147.      index values of size w*h.
  148.  
  149. fill-rectangle   ( index x y w h -- )
  150.      This method fills a screen rectangle, whose top-left is specified by x,y and whose size is specified by
  151.      w,h, with a constant index value specified by index.
  152.  
  153. read-rectangle   ( adr x y w h -- )
  154.      This method is the inverse of draw-rectangle.  I.e., it copies a screen bit-map, whose location and
  155.      size are specified by x,y and w,h, to the memory location specified by adr.
  156.  
  157.  
  158. References
  159.  
  160. [1]  IEEE Std 1275-1994 Standard for Boot (Initialization Configuration) Firmware, Core Practices and Requirements, published by IEEE.
  161.  
  162. [2]     ISO 6429, Information processing -- ISO 7-bit and 8-bit coded character sets -- Additional control functions for character-imaging devices, published by International Organization for Standardization.
  163.  
  164.